<!-- <template>
  <div class="box">
    <div class="search">
      <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
          <el-form-item label="学科名称">
            <el-input v-model="page.subjectName" size="small"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button size="small" @click="clear">清除</el-button>
            <el-button type="primary" size="small" @click="getsubjectsList">搜索</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div>
        <el-button
          type="success"
          size="small"
          icon="el-icon-edit"
          @click="showDialog = true"
          >新增学科</el-button
        >
      </div>
    </div>
    <el-alert title="数据一共21条" type="info" show-icon class="num">
    </el-alert>

    <template>
      <el-table
        :data="list"
        style="width: 100%"
        :header-cell-style="{ background: '#fafafa' }"
      >
        <el-table-column
          header-align="center"
          align="center"
          type="index"
          label="序号"
          width="48"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="subjectName"
          label="学科名称"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="username"
          label="创建者"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="addDate"
          label="创建日期"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="isFrontDisplay"
          label="前台是否显示"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="twoLevelDirectory"
          label="二级目录"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="tags"
          label="标签"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="totals"
          label="题目数量"
          width="160"
        >
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="address"
          label="操作"
        >
          <template slot-scope="{ row }">
            <el-button type="text" size="small" @click="$router.push('/subjects/directorys')">学科分类</el-button>
            <el-button type="text" size="small" @click="$router.push('/subjects/tags')">学科标签</el-button>
            <el-button type="text" size="small" @click="modification(row)"
              >修改</el-button
            >
            <el-button type="text" size="small" @click="remove(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="page.total"
          @current-change="changePage"
          :current-page="page.page"
          :page-size="page.size"
        >
        </el-pagination>
      </div>
    </template>
    <Windows :show-dialog.sync="showDialog" :amend="amend"></Windows>
  </div>
</template>
<script>
import { getsubjectsList, deletesubject } from '@/api/hmmm/subjects'
import Windows from '@/module-hmmm/components/jjq-add'
export default {
  data () {
    return {
      formInline: {
        user: '',
        region: ''
      },
      showDialog: false,
      // 表格数组
      list: [],
      page: {
        // 放置页码及相关数据
        page: 1,
        pagesize: 10,
        subjectName: '',
        total: 0 // 记录总数
      },
      amend: {
        subjectName: '',
        isFrontDisplay: '0'
      }
    }
  },
  components: {
    Windows
  },
  created () {
    this.getsubjectsList()
  },
  methods: {
    async getsubjectsList () {
      const { data } = await getsubjectsList(this.page)
      console.log(data)
      this.page.total = data.counts
      this.list = data.items
    },
    changePage (newPage) {
      this.page.page = newPage
      this.getsubjectsList()
    },
    modification (row) {
      this.showDialog = true
      this.amend = row
      console.log(this.amend)
    },
    clear () {
      this.formInline.user = ''
      this.getsubjectsList()
    },
    async remove (row) {
      try {
        await deletesubject(row)
        console.log(row)
        this.getsubjectsList()
        this.$message.success('删除成功')
      } catch (error) {
        this.$message.error('删除失败')
      }
    }
  }
}
</script>

<style scoped>
body {
  background-color: #f4f4f4;
}
.box {
  margin: 20px;
}
.search {
  display: flex;
  justify-content: space-between;
}
.num {
  margin-bottom: 15px;
}
.block {
  text-align: right;
  background-color: #fff;
}
.operation {
  display: flex;
  justify-content: space-between;
}
a {
  display: inline-block;
  margin: 0 5 0 5;
}
</style> -->
<template>
  <div>我是学科</div>
</template>
